<!DOCTYPE html>
<html class="bg-white" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加/修改角色</title>
    <link rel="stylesheet" th:href="@{/plugins/layui/css/layui.css}" media="all" />
    <link rel="stylesheet" th:href="@{/css/admin.css}" media="all" />
</head>
<script th:inline="javascript"> var ctx = [[@{/}]]; </script>
<body>
<form  id="jobForm" lay-filter="jobForm" class="layui-form model-form">
    <input type="hidden" value="" id="jobId" name="jobId">
    <div class="layui-form-item">
        <label class="layui-form-label">任务名称</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="jobName" name="jobName" lay-verify="required" placeholder="请输入任务名称">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">任务组名</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="jobGroup" name="jobGroup" lay-verify="required" placeholder="请输入任务组名">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">任务方法</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="methodName" name="methodName" lay-verify="required" placeholder="请输入任务方法">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">方法参数</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="methodParams" name="methodParams" lay-verify="required" placeholder="请输入方法参数">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">cron执行表达式</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="cronExpression" name="cronExpression" lay-verify="required" placeholder="请输入cron执行表达式">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">计划执行错误策略</label>
        <div class="layui-input-block">
            <select name="status" class="layui-input" lay-verify="required" lay-search="">
                <option value="">请选择</option>
                <option value="1">立即执行</option>
                <option value="2">执行一次</option>
                <option value="3">放弃执行</option>
            </select>
        </div>
    </div>
                <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <select name="status" class="layui-input" lay-verify="required" lay-search="">
                <option value="">请选择</option>
                <option value="0">正常</option>
                <option value="1">暂停</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">备注信息</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="remark" name="remark" lay-verify="required" placeholder="请输入备注信息">
        </div>
    </div>
            <div class="layui-form-item text-right">
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        <button class="layui-btn" lay-filter="addJob" lay-submit>保存</button>
    </div>
</form>
<!-- js部分 -->
<script th:src="@{/plugins/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/js/common.js}"></script>
<script>
    layui.use(['layer', 'form','admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
        var prefix = "system/log";

        var url = ctx+prefix+"/add";
        // 回显数据
        var post = admin.getTempData('t_Job');
        if(post){
            form.val('jobForm', post);
            url = ctx+prefix+"/edit";
        }


        // 表单提交事件
        form.on('submit(addJob)', function (data) {
            layer.load(2);
            console.log(url);
            $.post(url, data.field, function (data) {
                layer.closeAll('loading');
                if (data.code == 0) {
                    top.layer.msg(data.msg, {icon: 1});
                    admin.putTempData('formOk', true);  // 操作成功刷新表格
                    // 关闭当前iframe弹出层
                    parent.layer.close(parent.layer.getFrameIndex(window.name));
                } else {
                    top.layer.msg(data.msg, {icon: 2});
                }
            });
            return false;
        });
    });
</script>
</body>
</html>